package rmiServer;

import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;

import util.IFatorial;

public class FatorialRemote extends UnicastRemoteObject implements IFatorial {

	/**
	 * Classe de calculo do Fatorial
	 */
	// private static final long serialVersionUID = 1L;
	private int number = 0;

	protected FatorialRemote() throws RemoteException {
		// super();
		// this.number = 0;
	}

	private int fatorial(int value){
		if (value <= 1) 
			return 1;
		else
			return value * fatorial(value - 1);		
	}
	
	@Override
	public int calc() throws RemoteException {
		return fatorial(this.number);
	}

	@Override
	public void send(int number) throws RemoteException {
		this.number = number;
	}

}
